package com.ruoyi.common.enums;

/**
 * 质检方式类
 */
public enum QualityCheckMethod {
    SAMPLE_CHECK("0", "抽检"),
    FULL_CHECK("1", "全检"),
    EXEMPTION_CHECK("2", "免检");

    private final String code; // 质检方式的代码
    private final String description; // 质检方式的描述

    // 构造函数
    QualityCheckMethod(String code, String description) {
        this.code = code;
        this.description = description;
    }

    // 获取方式代码
    public String getCode() {
        return code;
    }

    // 获取方式描述
    public String getDescription() {
        return description;
    }

    // 根据方式代码获取对应的枚举项
    public static QualityCheckMethod fromCode(String code) {
        for (QualityCheckMethod method : QualityCheckMethod.values()) {
            if (method.getCode().equals(code)) {
                return method;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }
}
